|
|
|
|
|
|
|
UserLogin = True ' set flag
GoTo UserLoginExit ' exit
End If
End If
'
' did user max attempts?
If intTries = intMaxTries Then
MsgBox "Login failed - access denied", vbCritical, "User Login"
UserLogin = False
GoTo UserLoginExit
End If
'
' go try again
intAnswer = MsgBox("Invalid Login", vbRetryCancel + vbInformation, "User
Login")
If intAnswer = vbRetry Then
GoTo UserLoginAttempt
Else
UserLogin = False
GoTo UserLoginExit
End If
'
UserLoginExit:
Unload frmUserLogIn
'
Exit Function
'
LocalErr:
Err.Raise Err.Number, App.EXEName & ".usrObject", Err.Description
'
End Function |
|
|
|
|
|
|
|
|
The module in Listing 21.15 first sets some variables and then calls the login form and waits for the user to press OK or Cancel on the form. The default settings allow the user three login attempts. If the user presses the OK button on the form, the routine calls the CheckUser function to check for a valid user. If the user is valid, the routine stores the user's ID, updates the user's record in the secUsers table, and then exits. If the user cannot pass the security check after three tries, the login is terminated. |
|
|
|
|
|
|
|
|
Now let's code the CheckUser routine. This is the module that looks up the user ID and password to see if they match in the data table. Create a new Private function called CheckUser and enter the code in Listing 21.16. |
|
|
|
|
|